package com.tuandai;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.*;

/**
 *
 */
@SpringBootApplication
@EnableEurekaClient //基于spring-cloud-netflix依赖实现的 该注解包含@EnableDiscoveryClient，使用eureka为注册中心推荐使用EnableEurekaClient
//@EnableDiscoveryClient //基于spring-cloud-common依赖实现
@RestController
public class App {

    /**
     * 基于Rest服务实现
     * @return
     */
    @RequestMapping("/")
    public String home() {
        return "Hello world";
    }

    @RequestMapping("/say/hello")
    public String sayHello(@RequestParam(name = "name") String name){
        return "大家好。我是" + name;
    }
    @RequestMapping("/user/{name}")
    public String getName(@PathVariable String name,@RequestParam(name = "age") int age) {
        return "hello," + name+","+age;
    }

    @RequestMapping(value = "/users/user", method = RequestMethod.POST)
    public String say(@RequestParam("name") String name, @RequestParam("age") String age) {
        return name + ":" + age;
    }
    public static void main(String[] args) {
       new SpringApplicationBuilder(App.class).web(true).run(args);
        //SpringApplication.run(App.class,args);
    }
}
